<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/9/10
  Time: 16:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>用户管理首页</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/user.css">
    <script src="${pageContext.request.contextPath}/static/jquery/jquery-3.1.1.js"></script>
    <script src="${pageContext.request.contextPath}/static/jquery/jquery.validate.js"></script>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">

    <style>
        .showmessages{
            position: absolute;
            width: 100%;
            margin-top:120px;
        }
    </style>
</head>
<body>
        <div class="titleall">
            <div class="titleph">
                <img src="${pageContext.request.contextPath}/static/images/account.png" style="width:100%;height:100%;"/>
            </div>
            <div class="titleword">用户管理 >>> 用户列表</div>
        </div>
    <div class="rolephall1">
        <img src="${pageContext.request.contextPath}/static/images/uservis.png" style="width:100%;height:100%"/>
    </div>
        <form action="selectuser" method="post" id="selectuserform">
            <input type="text" class="selectbox" name="userName" placeholder="用户姓名 / Name of user"/>
            <input type="submit" value="查询" class="selectbutton"/>
        </form>
    <div class="shuxian"></div>
    <div class="rolephall">
        <img src="${pageContext.request.contextPath}/static/images/hostph.png" style="width:100%;height:100%"/>
    </div>
    <form action="selecthost" method="post" id="selecthostform">
        <input type="text" class="selectbox1" name="userHost" placeholder="业主姓名 / Name of host"/>
        <input type="submit" value="查询" class="selectbutton1"/>
    </form>
            <%--<div class="powerword">用户信息</div>--%>
            <%--<div class="roleph1">--%>
                <%--<img src="${pageContext.request.contextPath}/static/images/userinfo.png" style="width:100%;height:100%"/>--%>
            <%--</div>--%>
            <div id="tableall" class="showmessages">
            <table class="layui-table">
                <thead>
                <tr>
                    <th style="border:1px solid #999;text-align: center;color:#EC9D1A;font-weight:600;">序号</th>
                    <th style="border:1px solid #999;text-align: center;color:#EC9D1A;font-weight:600;">用户名称</th>
                    <th style="border:1px solid #999;text-align: center;color:#EC9D1A;font-weight:600;">用户住所</th>
                    <th style="border:1px solid #999;text-align: center;color:#EC9D1A;font-weight:600;">所属业主姓名</th>
                    <th style="border:1px solid #999;text-align: center;color:#EC9D1A;font-weight:600;">创建时间</th>
                    <th style="border:1px solid #999;text-align: center;color:#EC9D1A;font-weight:600;">最后通过门禁时间</th>
                </tr>
                </thead>
                <tbody id="clear" style="display: none">
                <script>var arr1=[]</script>
                <c:forEach items="${sessionScope.userlist}" var="user" varStatus="sta">
                    <tr id="userorder${sta.count}" class="rolerow1">
                        <td style="border:1px solid #999;color:#777;font-weight:600">${sta.count}</td>
                        <td style="border:1px solid #999">${user.user_name}</td>
                        <td style="border:1px solid #999">${hostlistall[sta.count-1].host_building}栋${hostlistall[sta.count-1].host_unit}单元${hostlistall[sta.count-1].host_housenumber}号</td>
                        <td style="border:1px solid #999">${hostlistall[sta.count-1].host_name}</td>
                        <c:if test="${user.user_createtime==nul}"><td style="border:1px solid #999"></td></c:if>
                        <c:if test="${user.user_createtime!=null}">
                            <td class="createtime" style="border:1px solid #999">${user.user_createtime}</td>
                        </c:if>
                        <c:if test="${user.user_lastpasstime==null}"><td style="border:1px solid #999"></td></c:if>
                        <c:if test="${user.user_lastpasstime!=null}">
                        <td class="passtime" style="border:1px solid #999">${user.user_lastpasstime}</td>
                        </c:if>
                    </tr>
                <script>arr1.push($("#userorder${sta.count}")[0])</script>
                </c:forEach>
                </tbody>
                <tbody id="biuuu_city_list"></tbody>
            </table>
                <div id="demo20"></div>
            </div>
</body>
<script src="${pageContext.request.contextPath}/static/frame/layui/layui.js" charset="utf-8"></script>
<script>
    var w=$(window).width();
    var h=$(window).height();
    $(".contentall").innerWidth(w+"px");
    var username="${sessionScope.userlist}";
    //alert(username)
    if(username=="[]"){
        $("#tableall").html("<div class='searchrole'><img src='${pageContext.request.contextPath}/static/images/cry.png'/><div class='noword'>您输入的用户不存在！</div></div>");
    }

    /**
     * 时间显示，调整格式
     */
    showtime();
    function showtime() {
        var createtime=$(".createtime");
        var lasttime=$(".lasttime");
        var passtime=$(".passtime");
        createtime.each(function () {
            //调用时间格式转换函数formatDateTime()
            $(this).text(formatDateTime($(this).text()))
        });
        lasttime.each(function () {
            //调用时间格式转换函数formatDateTime()
            $(this).text(formatDateTime($(this).text()))
        });
        passtime.each(function () {
            //调用时间格式转换函数formatDateTime()
            $(this).text(formatDateTime($(this).text()))
        });
    }
    /**
     *
     * 在页面上，转换时间格式
     * @param inputTime
     * @returns {string}
     */
    function formatDateTime(inputTime) {
        var date = new Date(inputTime);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        var minute = date.getMinutes();
        var second = date.getSeconds();
        minute = minute < 10 ? ('0' + minute) : minute;
        second = second < 10 ? ('0' + second) : second;
        return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
    };

    function nodeToString ( node ) {
        var tmpNode = document.createElement( "div" );
        tmpNode.appendChild( node.cloneNode( true ) );
        var str = tmpNode.innerHTML;
        tmpNode = node = null; // prevent memory leaks in IE
        return str;
    }
    function clear(){
        document.getElementById('clear').innerHTML=null;
    }

    layui.use(['carousel', 'laypage','laydate','form','upload','jquery'], function(){
        var carousel = layui.carousel
            ,form = layui.form
            ,$=layui.jquery
            ,upload = layui.upload
            ,laypage = layui.laypage
            ,laydate=layui.laydate

        //常规轮播
        carousel.render({
            elem: '#test1'
            ,arrow: 'always'
        });
        var data1= arr1;
        laypage.render({
            elem: 'demo20'
            ,count: data1.length
            ,jump: function(obj){
                //模拟渲染
                document.getElementById('biuuu_city_list').innerHTML = function(){
                    var arr = []
                        ,thisData = data1.concat().splice(obj.curr*obj.limit - obj.limit, obj.limit);
                    layui.each(thisData, function(index, item){
                        var itemstr=nodeToString(item);
                        arr.push(itemstr);
                    });
                    clear();
                    return arr.join('');
                }();
            }
        });
    });
    $(".selectbox").focus(function(){
        $(".selectbox").css("border","1px solid #333");
    });
    $(".selectbox").focusout(function(){
        $(".selectbox").css("border","1px solid #999");
    });
    $(".selectbox1").focus(function(){
        $(".selectbox1").css("border","1px solid #333");
    });
    $(".selectbox1").focusout(function(){
        $(".selectbox1").css("border","1px solid #999");
    });
</script>
</html>
